feat: add work system (forms, rules, engine) and CLI enhancements#1189
Closed
ohdearquant wants to merge 10 commits into
Closed
feat: add work system (forms, rules, engine) and CLI enhancements#1189ohdearquant wants to merge 10 commits into
ohdearquant wants to merge 10 commits into
Conversation
Existing ADRs 0004–0032: added forward-reference notices pointing to the governance ADR series (0041-0052). Also fixed pre-existing markdownlint issues (MD032 blanks-around-lists, MD040 code-fence language specs, MD028 blockquote blanks). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 0033: Unified Entity State Model (lifecycle × health × delivery) - 0034: Frontend Data & State Architecture (TanStack + SSE) - 0035: Design System & Component Library (shadcn/Radix) - 0039: Knowledge Substrate Minimal Interface (5th Branch manager) Foundation for the governance ADR series (0041-0052). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Twelve governance ADRs establishing the governed-orchestration substrate for lionagi: - 0041: Immutable Evidence Nodes - 0042: Task Certificate - 0043: Governed Tool Declaration - 0044: Tool Gates - 0045: Break-Glass Protocol - 0046: JIT Tool Grant - 0047: Agent Charter - 0048: Agent Segregation of Duties - 0049: Log Tier Governance - 0050: Operation Context - 0051: Tool Registry Allowlists - 0052: Policy Resolution All ADRs use lionagi primitives (Element, Pile, Tool, Branch managers) as integration points. Status: Proposed — pending validation via the governance show. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Navigation aids for the ADR corpus — glossary of governance terms and a reader's guide for navigating the ADR dependency graph. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Automated fix of MD032 (blanks-around-lists), MD040 (code-fence language), MD058 (blanks-around-tables) across ADRs 0003, 0007, 0010, 0015, 0016, 0018, 0020-0023, 0027. Pure formatting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…1189 CRIT-1: Delete 4 broken test files in tests/test_work/ that imported non-existent classes (Form, WorkItemStatus, WorkerEngine, StepDef, ChoiceSet, NumericRange, StringPattern). Keep only test_worker.py which imports real classes from lionagi.work.worker. Canonical tests live in tests/work/test_work_system.py (67 tests, all passing). CRIT-2: Replace signal.SIGALRM timeout in engine._run_task with concurrent.futures.ThreadPoolExecutor.future.result(timeout=...) which is safe to call from any thread (SIGALRM raises ValueError in non-main threads and is process-global, causing concurrent timeouts to clobber each other). CRIT-3: Add HANDLER_ALLOWED_MODULES allowlist to definition.py. resolve_handler() now validates the module prefix against the allowlist before importing, preventing arbitrary code execution (os.system, subprocess.call, etc.) from YAML/JSON config. MAJ-1: Add VALID_TRANSITIONS dict and WorkForm.transition_to() method that validates status transitions and raises ValueError for illegal moves (e.g., completed→draft). Add status guard in WorkEngine.submit() to reject forms in submitted/completed/error status. MAJ-2: Add ReDoS protection to Rule._check_pattern(). Enforce REGEX_MAX_INPUT_LENGTH (10,000 chars) and run the match in a thread with REGEX_MATCH_TIMEOUT (1s) via concurrent.futures, preventing catastrophic backtracking from nested quantifier patterns. MAJ-3: Replace _resolve_id's direct access to engine._lock and engine._items with new public methods engine.get_item(id) and engine.find_by_prefix(prefix). MAJ-4: Guard the bare `from .mcp import ...` in cli/main.py with try/except ImportError, assigning None fallbacks and guarding all call sites. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- WorkEngine.submit_async(): mirror the _submittable status guard already present in submit() so async callers cannot enqueue completed/errored forms - SchedulerEngine.find_by_prefix(): add missing method used by the CLI `li schedule pause/remove/resume <prefix>` path; without it those commands raise AttributeError at runtime Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t re-fire bug MAJ-5: Replace ThreadPoolExecutor context manager with manual lifecycle so shutdown(wait=False, cancel_futures=True) is called on timeout — the old `with` block called shutdown(wait=True) on __exit__, blocking the caller for the full duration of catastrophic backtracking. MAJ-6: In SchedulerEngine.mark_completed(), transition one-shot items (cron_expr=None, interval_seconds=None) to STATUS_COMPLETED when _compute_next_run() returns None, instead of leaving them STATUS_ACTIVE and letting them re-fire immediately on every tick. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ThreadPoolExecutor cannot reliably timeout Python `re` catastrophic backtracking because the GIL prevents the main thread from regaining control. ProcessPoolExecutor runs the match in a separate process with its own GIL, making kill-on-timeout effective. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ut + kill ProcessPoolExecutor cannot pickle re.Match results and cannot terminate running workers. Switch to explicit multiprocessing.Process with Queue for result passing (bool only, no Match object) and terminate()/kill() for reliable cleanup on timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
ohdearquant
added a commit
that referenced
this pull request
Jun 10, 2026
…1) (#1386) * feat(work): WorkForm + Rule/RuleSet slim re-cut (R2-1, supersedes #1231/#1189 work scope) Introduces lionagi/work/ as a greenfield module with WorkForm, FieldSpec, Rule, RuleSet — the validated core of the work system without the engine or CLI layers. 106 new tests, all green against an 8527-test full suite. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(work): address all PR #1386 review findings CRITICAL: remove false ReDoS thread-timeout protection (GIL blocks join; daemon thread burns CPU regardless). Replace with honest doc + tight 4096-char input cap. REGEX_MATCH_TIMEOUT removed from public API. HIGH: validate_form/fill_form accept optional ruleset= kwarg. Rules run after coercion; failures set status=error with errors in validation_errors. validate_form without ruleset is unchanged. MEDIUM: WorkForm and FieldSpec now inherit from Element, gaining UUID id, created_at, and metadata consistent with lionagi ecosystem. form_id becomes a str property alias over str(self.id). LOW: FieldSpec rejects incompatible default at construction time (new model_validator). RuleSet.add raises ValueError on duplicate rule_id. Tests: 135 work tests (was 106), 8556 total passed (zero regressions). New tests cover Element identity, default validation, ruleset integration, duplicate-id prevention, bool-as-int behaviour (pinned), length cap, and REGEX_MATCH_TIMEOUT absence assertion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
Closing after validation against today's main (2026-06-10 rewrite roadmap). Status: partially landed via re-cuts, rest superseded/dropped.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lionagi/work/: WorkForm (6-state lifecycle), Rule/RuleSet, WorkerDefinition, WorkEnginelionagi/cli/schedule.py:li schedule add/list/remove/pause/resumelionagi/cli/cleanup.py:li state cleanupfor operational hygienelionagi/cli/config.py: Config resolution cascade with provenancelionagi/cli/orchestrate/charter.py: Charter CLI integrationTest plan
uv run pytest tests/work/ tests/test_work/ tests/cli/test_cleanup.py -x -q🤖 Generated with Claude Code